Conversation
balacij
left a comment
There was a problem hiding this comment.
The bulk of the comments.
| , TMs [] [] | ||
| , TMs [] (Label : stdFields) | ||
| , GDs [] [] HideDerivation | ||
| , DDs [] [] HideDerivation | ||
| , IMs [] [] HideDerivation | ||
| , DDs [] (Label : stdFields) HideDerivation | ||
| , IMs [] ([Label, Input, Output, InConstraints, OutConstraints] ++ stdFields) HideDerivation |
There was a problem hiding this comment.
Input, Output, (In/Out)Constraints are rows that are only permitted for IMs. I'm not quite sure why. Are "inputs" not the input variables of a hypothetical function being defined?
There was a problem hiding this comment.
That's because 'definitions' don't have input/output, and many theories are relational, so again input/output makes no sense for them.
There was a problem hiding this comment.
I'm not quite sure I'm following. What is the difference between a data definition (which defines QDefinitions) and an EquationalModel-based (i.e., QDefinition-defining) instance model?
Is "input/output" in regard to the "system's" inputs, outputs, and intermediate variables? If so, I think that should still be relevant to data definitions, which can be used to interpret input variables to intermediate variables (e.g., for unit conversion, etc.), no?
There was a problem hiding this comment.
Do remember that "F = ma" is usually used to get 'a' as output, given F and m as input!
I think we ought to use different vocabulary for input and output of a system, and equations where some variables can be substituted for.
It is true that the intent of a data definition is that the new symbol is defined by the computation where we imagine substituting for the (implicitly occuring) variables in the RHS. A data-definition is implicitly a function.
| _quants = [] :: [QuantityDict], | ||
| _instModels = [] :: [InstanceModel], | ||
| _datadefs = [] :: [DataDefinition], | ||
| _quants = quantities, -- Odd: The Table of Symbols is mostly filled without this list!!!! Also, even though the table of symbols is being filled in, there is text "There are no symbols." placed above the table! | ||
| _instModels = instanceModels, -- Surprisingly, putting this here is not what triggers it to get rendered. | ||
| _datadefs = dataDefinitions, -- ^ |
There was a problem hiding this comment.
This is something that needs to be spun off into 2 new tickets.
- The SRS is rendered using the instance models and data definitions taken from the ChunkDB rather than here. We should probably change that.
- The Table of Symbols is partially rendered without filling in the
_quantsfield, but completely filled in when passing this list to it. This should be investigated a little bit more.
There was a problem hiding this comment.
The deeper questions are:
- where should the information come from? We used to do things "by hand" because there was no other choice. But, of course, Drasil should automate things as much as possible. So it is a good thing that some information comes from the theories rather than hand-built!
- what is the difference between the "background information" necessary, and the meta-data needed to build a particular system? And should that information be gathered? Divided up?
| equilibrium :: IdeaDict | ||
| equilibrium = nc "equilibrium" $ nounPhrase "equilibrium" "equilibria" |
There was a problem hiding this comment.
Once defined, never used! Should we be using it? If so, how?
There was a problem hiding this comment.
Never used because you're not "doing it right". For example, it should have been used on line 295, and indeed on line 202 as well.
There was a problem hiding this comment.
Unfortunately, none of the constructors for QuantityDicts let us give them a plain IdeaDict. All of the constructors are keen on extracting an IdeaDict from something else or creating one that is immediately associated with the Q-D-.
There was a problem hiding this comment.
I don't understand. On line 295, you could have gotten the nounPhrase by using the lens defined for that. What do you think the code should instead look like?
There was a problem hiding this comment.
I would have expected to be able to pass in the entire IdeaDict (seeing as QuantityDicts currently nest an IdeaDict), and for the QuantityDict to only carry a UID reference to said IdeaDict.
There was a problem hiding this comment.
You have the power to change Drasil: do it! Introduce new functions that let you do that. That's the fun part, of seeing things that should be better, and just improving them.
| equilibriumQ :: QuantityDict | ||
| equilibriumQ = mkQuant' -- A somewhat odd variant of `mkQuant` that re-orders argument and adds staging to the `Symbol` | ||
| "inEquilibrium" | ||
| (nounPhrase "in equilibrium" "all equilibria") -- duplicates the IdeaDict | ||
| Nothing -- UnitDefn | ||
| Boolean | ||
| (autoStage $ label "inEquilibrium") | ||
| Nothing -- "abbreviation String" |
There was a problem hiding this comment.
QuantityDict's mkQuant' and related smart constructors are interesting because they create their own IdeaDicts that they associate with themselves. QDefinition's mkQuantDef and related smart constructors are similar, except they also create a DefinedQuantityDict, which also creates a ConceptChunk. In the future, it might be that our smart constructors are stateful too (in reference to #2873 (comment)).
There was a problem hiding this comment.
This is indeed a sign that we're trying to be too clever. We need to rethink this.
| priceQ = mkQuant' | ||
| "priceQuant" -- duplicates the IdeaDict | ||
| (cn "price") | ||
| Nothing -- UnitDefn // FIXME: Uh oh! There's seemingly no way we can define a new unit: $CAD.s |
There was a problem hiding this comment.
I was expecting that I wouldn't be able to create numbers of the form $ X CAD, but that I would be able to create CAD units at least. I don't see a clear way to doing that without it being 'derived' from the SI unit system.
There was a problem hiding this comment.
I'm not sure that currencies are 'units', per se. They are a classification system, and we ought to support more of them than just SI.
There was a problem hiding this comment.
Ah, I hadn't realized that UnitDefn and our unit system in general was only meant for physical quantities following the SI.
There was a problem hiding this comment.
Right - it's a side-effect of Drasil being focused on scientific software, so that was the most important classification system. Types were second. Now we might need more classification systems to be added (and most likely, our code refactored to reflect this fact.)
| -- ^ I'm deliberately choosing to use applePrice here because I want to use this | ||
| -- in an instance model, which (I believe) should mean that there are only | ||
| -- 'concrete' variables (i.e., problem-related variables, not the abstract ones | ||
| -- imported from the hypothetical library that would contain equilibrium) |
There was a problem hiding this comment.
How can/should we differentiate between abstract and concrete variables?
There was a problem hiding this comment.
We should. Don't know if we currently can.
| (cn "equilibrium apple price") | ||
| Nothing -- UnitDefn | ||
| Real -- Space | ||
| (autoStage $ sub lP $ label "A,Eq") -- Hack because of lack of support for symbol "corners" in Drasil. |
There was a problem hiding this comment.
lack of adequate support*. Related to #1606.
| equilibriumPriceLinearSDQIM :: InstanceModel | ||
| equilibriumPriceLinearSDQIM = imNoDerivNoRefs | ||
| (equationalModel' equilibriumApplePriceLinearSDQD) | ||
| [] -- Inputs -- What are they? Why is this only here and not in the TM? | ||
| equilibriumApplePriceLinearSDQ -- Output -- not everything will have an output! | ||
| [UpFrom (Exc, int 0)] -- Output constraints: price > 0 -- why can't I put gtZerConstr | ||
| "equilibriumApplePriceIM" | ||
| [] -- Notes ([Sentence]) |
There was a problem hiding this comment.
The important bit is really the QDefinition, which contains a DefinedQuantityDict (DQD) and a defining formula for the DQD. Now:
- What are the "inputs"? If the DQD is a function (i.e., a function-typed variable), is it the inputs to the function? In Projectile's
IM:calOfLandingDist,$p_\text{land}$ is noted as having two inputs:$v_\text{launch}$ and$\theta$ , but$p_\text{land}$ is not a function. If it should be (and I don't think it should be), then why is$g$ not a part of its inputs? - Why isn't the list of input and output variables and their corresponding constraints in the
QDefinition. Same with the notes. Why wouldn't they be part of theQDefinition? - While we're here, why not the derivation and the references?
There was a problem hiding this comment.
I think input and output are / ought to be theory-level concepts and not chunk-level.
There was a problem hiding this comment.
I agree that input and output should be at the theory level.
For the specific example of
| {- | ||
| DefinedQuantityDict seems like a wart. It seems like it's only necessary when | ||
| we want to assert that a quantity has an English interpretation along with a | ||
| mathematical one (i.e., a variable). | ||
| -} |
There was a problem hiding this comment.
It seems like D-Q-D really just wants to be smart constructor as I mentioned earlier. There's no reason why a QuantityDict couldn't also have a description.
| -- | Renders definition tables (Data, General, Theory, etc.). | ||
| makeDefn :: L.DType -> [(String,[LayoutObj])] -> Doc -> Doc | ||
| makeDefn _ [] _ = error "L.Empty definition" | ||
| makeDefn _ [] _ = error "Definition table has no designated rows to render!" |
There was a problem hiding this comment.
Probably something that should just be ported over to main.
| , TMs [] [] | ||
| , TMs [] (Label : stdFields) | ||
| , GDs [] [] HideDerivation | ||
| , DDs [] [] HideDerivation | ||
| , IMs [] [] HideDerivation | ||
| , DDs [] (Label : stdFields) HideDerivation | ||
| , IMs [] ([Label, Input, Output, InConstraints, OutConstraints] ++ stdFields) HideDerivation |
There was a problem hiding this comment.
That's because 'definitions' don't have input/output, and many theories are relational, so again input/output makes no sense for them.
| _quants = [] :: [QuantityDict], | ||
| _instModels = [] :: [InstanceModel], | ||
| _datadefs = [] :: [DataDefinition], | ||
| _quants = quantities, -- Odd: The Table of Symbols is mostly filled without this list!!!! Also, even though the table of symbols is being filled in, there is text "There are no symbols." placed above the table! | ||
| _instModels = instanceModels, -- Surprisingly, putting this here is not what triggers it to get rendered. | ||
| _datadefs = dataDefinitions, -- ^ |
There was a problem hiding this comment.
The deeper questions are:
- where should the information come from? We used to do things "by hand" because there was no other choice. But, of course, Drasil should automate things as much as possible. So it is a good thing that some information comes from the theories rather than hand-built!
- what is the difference between the "background information" necessary, and the meta-data needed to build a particular system? And should that information be gathered? Divided up?
| equilibrium :: IdeaDict | ||
| equilibrium = nc "equilibrium" $ nounPhrase "equilibrium" "equilibria" |
There was a problem hiding this comment.
Never used because you're not "doing it right". For example, it should have been used on line 295, and indeed on line 202 as well.
| equilibriumQ :: QuantityDict | ||
| equilibriumQ = mkQuant' -- A somewhat odd variant of `mkQuant` that re-orders argument and adds staging to the `Symbol` | ||
| "inEquilibrium" | ||
| (nounPhrase "in equilibrium" "all equilibria") -- duplicates the IdeaDict | ||
| Nothing -- UnitDefn | ||
| Boolean | ||
| (autoStage $ label "inEquilibrium") | ||
| Nothing -- "abbreviation String" |
There was a problem hiding this comment.
This is indeed a sign that we're trying to be too clever. We need to rethink this.
|
|
||
| priceQ :: QuantityDict | ||
| priceQ = mkQuant' | ||
| "priceQuant" -- duplicates the IdeaDict |
There was a problem hiding this comment.
It is technically a duplication -- but it shouldn't be, because the 'concept' of a price, and a variable that holds a 'price' value are completely different. And the bug is that you shouldn't do (cn "price") below but refer to price ^. term instead.
| Nothing -- UnitDefn | ||
| (mkFunction [Real] Integer) | ||
| (autoStage $ sub cS lL) | ||
| Nothing -- Abbreviation |
There was a problem hiding this comment.
SCS has tons of abbreviations. Maybe it's just that finance has less so for fundamental quantities?
| linearDemandQ :: QuantityDict | ||
| linearDemandQ = mkQuant' | ||
| "linearDemandQuant" | ||
| (pn "price-dependant apple demand") |
There was a problem hiding this comment.
here all the pns below: I think you're abusing pn here, a different constructor should be used.
Also, these 'noun phrases' should be built compositionally! The word 'apple' should never be repeated or even mentioned in all of thse (in the source). Similarly, demand, marginal, supply and price should all be abstracted.
| -- ^ I'm deliberately choosing to use applePrice here because I want to use this | ||
| -- in an instance model, which (I believe) should mean that there are only | ||
| -- 'concrete' variables (i.e., problem-related variables, not the abstract ones | ||
| -- imported from the hypothetical library that would contain equilibrium) |
There was a problem hiding this comment.
We should. Don't know if we currently can.
| linearSupplyDD = ddENoRefs | ||
| linearSupplyQD | ||
| Nothing -- Derivation | ||
| "linearSupplyDD" -- "ShortName" |
There was a problem hiding this comment.
I thought short names were for human consumption!?
| equilibriumPriceLinearSDQIM :: InstanceModel | ||
| equilibriumPriceLinearSDQIM = imNoDerivNoRefs | ||
| (equationalModel' equilibriumApplePriceLinearSDQD) | ||
| [] -- Inputs -- What are they? Why is this only here and not in the TM? | ||
| equilibriumApplePriceLinearSDQ -- Output -- not everything will have an output! | ||
| [UpFrom (Exc, int 0)] -- Output constraints: price > 0 -- why can't I put gtZerConstr | ||
| "equilibriumApplePriceIM" | ||
| [] -- Notes ([Sentence]) |
There was a problem hiding this comment.
I think input and output are / ought to be theory-level concepts and not chunk-level.
Do Not Merge (DNM).
We can use this to discuss encoding equilibrium in Drasil and spin issues off this PR if necessary.
I will annotate the PR first.
I've only encoded equilibrium in the context of a simple supply/demand curve thus far.